Blending Operations
A drawing engine may support a transparency blending function that determines the kind of transparency blending applied to a drawing context when combining new ("source") pixels with the pixels already in a frame buffer ("destination"). You specify an engine's transparency blending function by assigning a value to itskQATag_Blend
state variable. The default value of this variable for a draw context that supports transparency blending iskQABlend_PreMultiply
.In the equations below, the factors as, rs, gs, and bs represent the alpha, red, green and blue components of a source pixel; the factors ad, rd, gd, and bd represent the alpha, red, green and blue components of a destination pixel.
#define kQABlend_PreMultiply 0 #define kQABlend_Interpolate 1 #define kQABlend_OpenGL 2Constant descriptions
kQABlend_PreMultiply
- The drawing engine uses a premultiplied blending function. The components of a pixel written to the frame buffer are computed using these equations:
- In general, you should use the premultiplied blending function for rendering shaded transparent 3D primitives (such as triangles). The premultiplied function does not scale the source color components by the alpha value as; as a result, this function allows a transparent object to have a specular highlight value that is greater than its alpha channel value. For example, a sheet of glass might allow 99% of the light behind it to pass though (indicating an alpha channel value of 0.01). However, that same sheet of glass might have a specular highlight value much greater than 0.01. The premultiplied function allows the drawing engine to render this object correctly.
kQABlend_Interpolate
- The drawing engine uses an interpolated blending function. The components of a pixel written to the frame buffer are computed using these equations:
- The interpolated blending function is not entirely suitable for rendering shaded transparent objects, but it is very effective for compositing bitmap images.
kQABlend_OpenGL
- The drawing engine uses the OpenGL blending function determined by the values of the
kQATagGL_BlendSrc
andkQATagGL_BlendDest
state variables. For complete information on OpenGL blending functions, consult the description of theglBlendFunc
function in OpenGL(TM) Reference Manual. OpenGL blending functions are supported only by drawing engines that support thekQAOptional_OpenGL
feature.